package com.flink.wc.demo.demo_20240807;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;

public class Demo01 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setRuntimeMode(RuntimeExecutionMode.BATCH);
        StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
        tableEnv.executeSql(" CREATE TABLE source (\n" +
                "            line STRING\n" +
                "        ) WITH (\n" +
                "            'connector' = 'filesystem',\n" +
                "            'format' = 'text',\n" +
                "            'path' = '{'E:\\mywork\\FlinkDemo-1.19\\src\\main\\java\\com\\flink\\wc\\demo\\demo_20240807\\hello.txt'}'\n" +
                "        )");
        Table sqlQuery = tableEnv.sqlQuery("select * from source");
        tableEnv.toDataStream(sqlQuery).print();
        env.execute();
    }
}
